package com.liangwj.springbootdesignpatterns.createTypePatterns.ProtoType;

import lombok.Data;

/**
 * <b>Description:</b> 具体原型角色：EmailObject <br/>
 * 实现了 Cloneable接口的类
 * 用于完成对象的复制, 完成通过自身的对象复制生成一个新的对象
 * @author Lingwenjun
 * @date 2019/1/22-18:00
 * @version 1.0
 */
@Data//不管是new出来的对象还是复制出来的都可以调用getting, setting方法
public class EmailObject implements Cloneable{

    private String receiver;

    private String title;

    private String context;

    public EmailObject(String title, String context) {
        this.title = title;
        this.context = context;
    }

    //重写Object的clone方法
    @Override
    public EmailObject clone() {
        EmailObject emailObject = null;
        try {
            emailObject = (EmailObject) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return emailObject;
    }

}
